import request from '@/utils/request'
enum API{
    SPUURL='/admin/product/',
    // 全部品牌接口
    TMURL='/admin/product/baseTrademark/getTrademarkList',
    //全部销售属性接口
    ALLSALEATTR='/admin/product/baseSaleAttrList',
    //已有SPU照片墙的接口
    IMGLIST="/admin/product/spuImageList/",
    //获取【SPU】已有的销售苏醒
    HAVESALEATTR="/admin/product/spuSaleAttrList/",
    ADDSPU='/admin/product/saveSpuInfo',
    // 修改已有的spu
    UPDATESPU='/admin/product/updateSpuInfo',
     //平台属性
     ATTR="/admin/product/attrInfoList/",
      //获取SKU列表
    FINDSKU='/admin/product/findBySpuId/',
    //删除SPU
    DELETESPU="/admin/product/deleteSpu/",
     //添加SKU
     ADDSKU="/admin/product/saveSkuInfo",
}
export const reqSpuList=(page:number,limit:number,category3Id:string|number)=>request.get(API.SPUURL+`${page}/${limit}?category3Id=${category3Id}`)

// 全部品牌接口
export const reqAllTrademark=()=>request.get(API.TMURL)
//全部销售属性接口
export const reqAllSaleAttr = ()=>request.get(API.ALLSALEATTR);
//已有SPU照片墙的接口
export const reqImgList = (spuId:number)=>request.get(API.IMGLIST+spuId);
//获取【SPU】已有的销售苏醒
export const reqSpuHasSaleAttr=(spuId:number)=>request.get(API.HAVESALEATTR+spuId);

// 添加或修改
export const reqAddOrUpdateSpu=(data:any)=>{
    if(data.id){
        return request.post(API.UPDATESPU,data)
    }else{
        return request.post(API.ADDSPU,data)
    }
}
//平台属性请求
export const reqAttrList = (category1Id:string|number,category2Id:string|number,category3Id:string|number)=>request.get(API.ATTR+`${category1Id}/${category2Id}/${category3Id}`);
//查看SKU列表
export const reqFindSkuList = (spuId:number)=>request.get(API.FINDSKU+spuId);

//删除SPU
export const reqDeleteSpu = (spuId:number)=>request.delete(API.DELETESPU+spuId);
//添加SKU
export const reqAddSku = (data:any)=>request.post(API.ADDSKU,data);

